/*Copyright (C) 2009 - 2011 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "../headers.h"

long snake_afficher_barre_vitesse(long vitesse) {
	long touche_selection = '0';
	int j;
	afficher_titre("SNAKE");
	CSLP_ColorText(CT);
	addstr("\n\nPour diminuer  la vitesse du serpent, appuyer sur → .\nPour augmenter la vitesse du serpent, appuyer sur ← .\n");

	while(touche_selection != '\r' && touche_selection != '\n' && touche_selection != '\b') {

		CSLP_ColorText(CT);
		addstr("\nLa vitesse actuelle du serpent est de ");
		CSLP_ColorText(COLOR_RED);
		addstr("1 ");
		CSLP_ColorText(CT);
		addstr("déplacement toutes les ");
		CSLP_ColorText(COLOR_RED);
		printw("%li ", vitesse);
		CSLP_ColorText(CT);
		addstr("millisecondes. \n\n");
		CSLP_ColorText(CT);
		refresh();

		touche_selection = afficher_barre(50, 300, 10, vitesse);

		if(touche_selection == KEY_LEFT && vitesse != 50) {
			vitesse -= 10;
		}

		else if(touche_selection == KEY_RIGHT && vitesse != 300) {
			vitesse += 10;
		}

		for(j = 0; j != 8 ; j++) {
			goto_previous_line();
		}

		goto_begin_line();
	}

	return vitesse;
}
